
using B.S.BasicData.Infrastructures;
using Microsoft.EntityFrameworkCore;
using NLog.Web;
using System.Reflection;
namespace B.S.BasicData.Api.Read
{
    /// <summary>
    /// ������
    /// </summary>
    public class Program
    {
        public static void Main(string[] args)
        {
            var builder = WebApplication.CreateBuilder(args);
            //������
            builder.Services.AddDbContext<MyDbContext>(x => { x.UseSqlServer(builder.Configuration.GetConnectionString("Conn")); });
            //��־
            builder.Host.UseNLog();
            //注册AutoMapper
            builder.Services.AddAutoMapper(typeof(MapperProFiles));
            // Add services to the container.
            //�н���
            builder.Services.AddMediatR(x => x.RegisterServicesFromAssemblies(Assembly.GetExecutingAssembly()));
            //ע��ִ�
            builder.Services.AddScoped(typeof(IBaseRepository<>), typeof(BaseRepository<>));
            builder.Services.AddControllers();
            // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
            builder.Services.AddEndpointsApiExplorer();
            //����ע��
            builder.Services.AddSwaggerGen(x => {

                var file = Path.Combine(AppContext.BaseDirectory + "B.S.BasicData.Api.Read.xml");
                x.IncludeXmlComments(file, true) ;
            });

            var app = builder.Build();

            // Configure the HTTP request pipeline.
            if (app.Environment.IsDevelopment())
            {
                app.UseSwagger();
                app.UseSwaggerUI();
            }
            //����
            app.UseCors(x=>x.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());
            app.UseAuthorization();


            app.MapControllers();

            app.Run();
        }
    }
}
